@extends('layouts.default')
@section('title', '主页')
@section('content')
<div class="layui-col-md6 layui-col-md-offset2">
  <div class="layui-card">
    <div class="layui-card-header">
    </div>
    <div class="layui-card-body">
      @if (Auth::check())
        @include('statuses._status_form')
        <br>
        <h2>微博列表</h2>
        <hr>
        @include('shared._feed')
      @else
        <h1>Hello Laravel</h1>
        <p class="lead">
          你现在所看到的是 <a href="https://learnku.com/courses/laravel-essential-training">Laravel 入门教程</a> 的示例项目主页。
        </p>
        <p>
          一切，将从这里开始。
        </p>
        <p>
          <a class="layui-btn" href="{{route('signup')}}">现在注册</a>
        </p>
      @endif
    </div>
  </div>
</div>
@if (Auth::check())
<div class="layui-col-md2">
  <div class="layui-card">
    <div class="layui-card-header">
      <h2>{{Auth::user()->name}}</h2>
    </div>
    <div class="layui-card-body">
      @include('shared._stats',['user'=>Auth::user()])
    </div>
  </div>
</div>
@endif

@endsection

@section('js')
<script>
  layui.use(['laypage','form'], function(){
    var laypage = layui.laypage;
    var form = layui.form;
    //执行一个laypage实例
    laypage.render({
      elem: 'home-status-pages' //注意，这里的 test1 是 ID，不用加 # 号
      ,count: {{$count??''}}        //数据总数，从服务端得到
      ,curr: {{$curr??''}}          //获取起始页
      ,jump: function(obj, first){
        //首次不执行
        if(!first){
          var url = "{{ route('home')}}" + "?page=" + obj.curr;
          window.location.href = url;
        }
      }
    });
  });
</script>
@endsection


